<?php
/*
 * Author: Quan Van Sinh
 * Email: sinhvnb@vietnambiz.com
 */
checkLoginHeader();
checkPermission();
$comment = new comment();
$comment->commentAction();
?>
<?php include_once $config ['admin_theme_path'] . $config ['admin_theme'] . '/header.php'; ?>


<script type="text/javascript">

    function deleteAllComment(id){
        if (confirm("Do you want to delete all comments of this article?")){
            $.ajax({
                url: '/<?php echo $config ['admin_section']; ?>/comment',
                type: 'POST',
                data: "id="+id+"&commentActionType=deleteAllComment",
                error: function(){
                    alert('Connection error!');
                },
                success: function(){
                    window.location = "/<?php echo $config ['admin_section']; ?>/comment";
                }
            });
        }
    }

    $(document).ready(function(){
        setTimeout("closeResultMessages()",5000);
    });
    function closeResultMessages(){
        document.getElementById('rsMessages').style.display = 'none';
    }
    

</script>

<div id="wrapper">
    <div id="content" style="width: 98%;">


        <div id="rightnow">
            <h3 class="reallynow">
                <span>Article have comments</span>

                <br />
            </h3>
            <div class="youhave">
                <div id="rsMessages" style="text-align: center; color: red; font-weight: bolder"><? if (isset($_SESSION['rsMessages'])) {
    echo $_SESSION['rsMessages'];
    $_SESSION['rsMessages'] = '';
} ?></div>
                <table width="100%">

                    <tbody>
                        <tr>
                            <td width="40px"><font title="Total not active">NA</font>|<font title="Total actived">A</font></td>
                            
                            <td><b>Article title</b></td>

                            <td width="40px"><b>Action</b></td>
                        </tr>
                        <?php
                        $comment = $comment->getAllArticleHaveComment();
                        $i = 0;
                        while ($rs = $db->fetch_array($comment['rs'])) {
                            $i++;
                            if ($rs['status'] == 'yes') {
                                $frontPageImg = 'circle-green.png';
                                $frontPageTitle = 'Comment is actived!';
                            } else {
                                $frontPageImg = 'circle-red.png';
                                $frontPageTitle = 'Comment is not actived!';
                            }
                            
                        ?>

                            <tr>
                                <td class="a-center"><?php echo intval($rs['num_comment_notactive']).'|'.intval($rs['num_comment_active']); ?></td>
                                <td>
                                    <a href="/<?php echo $config ['admin_section']; ?>/comment?id=<?php echo $rs['article_id'];?>&commentActionType=viewComment"><font style="color: black;<?php echo intval($rs['num_comment_notactive'])>0?'font-weight:bold;':'';?>"><?php echo $rs['title']; ?></font></a>
                                </td>
                                <td>
                                    <a href="/<?php echo $config ['admin_section']; ?>/comment?id=<?php echo $rs['article_id'];?>&commentActionType=viewComment">
                                        <img height="16" width="16" title="View this article's comments" src="<? echo $config ['admin_images_url']; ?>/icons/page_white_text_width.png"/>
                                    </a>
                                    <a href="javascript: deleteAllComment('<?php echo $rs['article_id']; ?>');">
                                        <img height="16" width="16" title="Delete all comments" src="<? echo $config ['admin_images_url']; ?>/icons/page_white_delete.png"/>
                                    </a>
                                </td>
                            </tr>

                        <?php
                        }
                        ?>


                    </tbody>
                </table>
            </div>
            <div class="linepagination">
                <div class="pagination">
                    <ul>
                            <?php
                            echo pagingAdmin($config ['page'],$comment['totalPages'],'','');
                            ?>
                    </ul>
                </div>

            </div>

        </div>
    </div>


</div>
<?php include_once $config ['admin_theme_path'] . $config ['admin_theme'] . '/footer.php'; ?>